package com.gzhryc.shared_device.cdb.core.protocol.v1.msg;

import com.gzhryc.common.IDTools;
import com.gzhryc.common.secruity.CRC16;

import java.io.Serializable;

public class FARequest implements Serializable {

	private static final long serialVersionUID = 1L;

	private String cmd = "FA";
	private Integer slotNum;
	private String messageId;
	
	public FARequest() {
		this.messageId = IDTools.getTimestampSecondID();
	}
	
	public String getCmd() {
		return cmd;
	}
	public void setCmd(String cmd) {
		this.cmd = cmd;
	}

	public Integer getSlotNum() {
		return slotNum;
	}

	public void setSlotNum(Integer slotNum) {
		this.slotNum = slotNum;
	}

	public String getMessageId() {
		return messageId;
	}
	public void setMessageId(String messageId) {
		this.messageId = messageId;
	}
	
	public String getData() {
		String data = cmd + "," + messageId + "," + slotNum;
		return data;
	}

	public String getMessage() {
		String data = getData();
		String crc16 = CRC16.get((data + "," + BaseMessage.MESSAGE_KEY).getBytes());
		return "{" + data + "," + crc16 + "}";
	}
}
